/*var validity = {
	"errors": undefined
};*/

(function () {
	var alt = false,
		shift = false;

	//	Init Page Action
	chrome.extension.sendRequest({
		"action": "init",
		"host": document.location.host,
		"renderMode": document.compatMode,
		"useCache": true
	});

	//	Set up keyboard shortcuts (Alt + Shift + V)
	document.addEventListener("keydown", function (e) {
		if (e.which === 16) {
			shift = true;
		}
		else if (e.which === 18) {
			alt = true;
		}
		else if (e.which === 86) {
			if (alt && shift) {
				validateDocument(false);
			}
		}
	}, false);

	document.addEventListener("keyup", function (e) {
		if (e.which === 16) {
			shift = false;
		}
		else if (e.which === 18) {
			alt = false;
		}
	});

	function validateDocument (useCache) {
		chrome.extension.sendRequest({
				"action":"validate",
				"host": document.location.host,
				"useCache": useCache,
				"renderMode":document.compatMode
			},
			function (errorCount) {
			//validity["errors"] = errorCount;
		});
	}
})();